<?php

namespace app\admin\model;

use think\Model;


class Litestorecart extends Model
{

    

    

    // 表名
    protected $name = 'litestore_cart';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [

    ];
    

    

    public function getTotalNum($uid){
        $total = $this->where('uid',$uid)->sum('num');
        return $total;
    }



    public function goods()
    {
        return $this->belongsTo('Litestoregoods', 'goods_id', 'goods_id', [], 'LEFT')->setEagerlyType(0);
    }

    public function spec()
    {
        return $this->belongsTo('Litestoregoodsspec', 'spec_sku_id', 'spec_sku_id', [], 'LEFT')->setEagerlyType(0);
    }


}
